Form Designer
BMC Forms Designer

by Mike Richardson

What you specifically have to do

Overview

Problem

You have forms in a VB project with inputs on them.

You need to provide checks and help on the inputs e.g. :

Are numbers only allowed, if so how many decimals, minimum, maximum values, length?

Is a date string expected, if so is it in the correct format, and is validation (including the warning text) then automatic (you have to write your own if you use a masked edit box)?

Should text be automatically all changed to upper case or only the first letter of each word?

Items for combo and list boxes are needed at form load time.

You want prompt text on the bottom line, like most modern programs. You need to hold this text and message strings externally because you may have different language versions of your product.

You want true context sensitive help in a pop-up window which can stay visible and changes dynamically as you move input focus (unlike the windows help file which is context sensitive when it pops up but then doesnt change unless you press help again. It also needs a new page for every topic, i.e. every input on a screen to be truly context sensitive, otherwise you must group inputs together on 1 page and the user must then search through for the relevant one.)

There is no VB equivalent of resource files.

Solution!

The form designer scans a form and automatically picks up the names of all controls which have a GotFocus event.The form designer for VB for WINDOWS then lets you edit and store an input mask plus prompt and help text for all controls on the form which can gain focus. The data is stored in a separate MS Access format file which is then used at run time by the application. In addition to the usual text, number and date formats, the mask has 5 user defineable flags for customisation.

This means that the application's input mask is easily viewable and editable and can also be checked. The range of input masks is also greater. Help and prompt text in pop up boxes can also be easily provided and the text spell checked by exporting to your favourite Word processor and then re-importing to FDES.

All the entries can be exported to ASCII files for easier checking, instead of having the setting buried away in the code. The help text can also then be used as the basis for a complimentary Windows help file.

The designer sets up a table for each form in your project. This is editable as a form for each control or as a grid for all controls. The grid has search and replace facilities including an optional search on one field only, allowing you to change a whole range of settings.

The designer automatically sets up extra Project tables for strings, constants, min/max,  and items (for list/combo boxes), the latter two so that you can easily store and re-use common settings e.g. for min/max  minimum, maximum ages for all customers and for items  e.g. Mr, Mrs, Ms, Miss, Master.

There is also a ProjectNotes table set up to store notes on each screen e.g. peculiarities, who last changed it etc etc.

Multi-Lingual applications - end the search for text buried away in code. Just re-import the correct ASCII files!

Finally, FDES will automatically generate code ready to paste into your application. This code is for the calls that allow reading of the database produced, display of the help text, filter of keypresses at keypress time and checking of a box contents on lostfocus. For boxes like command boxes, code is also generated to move focus to the control when the right-hand mouse button is clicked, thus generating the help and prompt text (which is also generated if the user TABs to the control).


What you must do
What you specifically have to do

Installing and customising FDES

The sample program

The Main Form - A

The Main Form - B

The Overview Form

The ProjectForm

Tips on designing your form

Running FDES

Using the resulting Database file

Things still to do yourself

See a graph


Main Screen, Numeric Inputs
The Main Screen, Numeric Inputs

Notice how the number of decimals, minimum and maximum boxes appear when item 5 is selected as the data type for this input.


Main Screen, Combo and List boxes
The Main Screen, LIST and COMBO Boxes

Note how the extra box in the bottom left hand corner has appeared for you to enter the ADDITEM strings

In this case, non-numeric input has been chosen for a combo box, so the numeric limit boxes have gone. For a List box or drop down combo where the user cannot input anything, the length, and type of input settings are ignored.

The loading up of the items in the combo/list is done on form load and the code for this is generated automatically by FDES using the File, gencode menu item.


Overview Screen, Edit all records
The Overview Screen

This allows you to see and edit the whole database at once in a grid view instead of the single control view presented on the main screen.

Note the find and find and replace sub menu items under the edit menu. Especially useful is the ability to change one field (column) only. You could use this to reset say the length of a whole series of input controls very quickly.

Similarly, use the ability to cut and paste text if say a series of controls have the same help text.

NB If you run at a higher resolution than 640*480, you can re-size this screen!

If you have MS Access, you can also use this to edit in the same way.


The Project Form, Strings, Constants, Min/Max, Lists
The Project Screen

This is the screen where you store all the strings,constants, min/max vals and common list values. (The latter two so you can paste into the main screen for individual controls but still maintain a common set for all forms in the application).

Note the Strings and Constants can be exported to ASCII files for easy paste, checking etc.


Designing the application, Tips
Design Criteria

(and limitations in small print)

Types of input covered

The designer copes only with control types which have a GotFocus event, (e.g. Text boxes, Combo boxes, List boxes, Masked edit boxes, Command boxes etc. etc.). This is because these are the only boxes that the user can focus on and therefore needs help on.

You need an input mask for the input type boxes and just help and prompt text for e.g. command boxes which can get focus but have no key input.

It is strongly suggested that each type of input control is part of a control array for ease of controlling input. It is NOT necessary for the form designer to work however.

Why use Tag names?

Boxes do not need to have an associated tag name. The input box type is identified on the form designer screen by name and type and there is a facility to point to the box on your form. However, tag names do make it easier for you to identify boxes (without a tag name, text1(21) is hardly intuitively understood!)

Other thoughts of chairman Mao

The help text box and prompt line box were provided because VB does not provide these for you. You would either have to put the help in a WINDOWS help file (and require the user to continually keep it loaded and press the help key to update it, - a disaster for context sensitive help) or code the text by embedding in the application.

The same problem applies to strings for e.g. message boxes, common constants (State Retirement age, Tax rates etc) that may be used in your project

er that's it!


Running FDES
Running the FDES program

State of the application program

This can be running as an .exe, or running in VB design mode or be not running in design mode. Just make sure you have the form you want to design for visible!

We suggest you follow the flow chart.

Saving

As you start the program, a back-up file is made. At the very end of the program, when you exit, you are given the choice of retaining your changes during the session or going back to the previous version.

As you select a new control from the list of controls, the inputs for the old control are automatically saved.

Moving around

Changing the control by using the drop down list, the spin button below or using the point command to point at a control. For this latter facility, if you are in design mode, make sure the control is not selected. Note the use of the OnTop menu item to help with this.

Help text

Note that each help text box is limited to a mere 32,767 characters of entry. Try to be concise therefore and do not fill it and force the user to scroll through a hundred or so pages!

To make it easy to import/export help text, note the clipboard use within the edit command. This works with all input boxes on the form.

Tip - write all the help and prompt text in one go in a word processor so you can spell check it. Then use the clipboard to import it into FDES.

OR better still, use export help to generate an ASCII file with the relevant control names in but no help/prompt text actaully there, add the help/prompt text and then import the whole file at once.

Help Import and Export

Note that under the file menu, you can export all the help and prompt text to an ASCII file. This is so you can then import it into your favourite word processor for spell checking and to see if the grammar is wot it orta be. For multi-lingual applications, this will also aid translation.

When it has been checked, you can then re-import it into the main file again.

You can alter the length of the text (but remember prompt text can only be 1 line).

NB Make sure you do not add any new sections or alter any of the VBControlName lines since the import program relies on these to know where to place the text.

Also, under NO CIRCUMSTANCES try to import help text after you have altered the database file in any way.

Multi Lingual Applications

See the help notes above.

Also keep separate Database files for each language. Since the control names will be the same, you can translate and then re-import the text into the relevant database file. You can also store the Project Strings in the correct language and use the same names for the strings so you do not need to change code.

To duplicate the database file, just copy the two files (.MDB and .LDB) to a different directory, re-name them and then place them back again.

Exporting the FDES settings

A sub to the File menu lets you export all the stored FDES inputs to an ASCII file. This has a format very similar to a .ini file and is obvious in format, but see below anyway!. It allows easy checking of all parameters as an overview and also for documented back-up. The file has the same name as the binary file but with the extension .exp. You can view it in Notepad, Write or your favourite word processor (i.e. even WordStar!).

Export of help/prompt from SimpleTest

Exported on 29/12/1993  at  13:48:35 hrs

Note that if not shown, field is blank or n/a.

VBControlName: Check1

[Help]

Check box1 help, amended again

[Prompt]

Check box1 prompt, amended again

[End]

VBControlName: Option1

[Help]

Option1 help, amended

[Prompt]

Option1 prompt, amended

[End]

VBControlName: Picture1

[Help]

Picture1 help, amended again

[Prompt]

Picture1 prompt, amended again

[End]

Adding or deleting input boxes on the Application Form

NEVER do this while the Form design program is running. At start up, the program reads in and stores all the names for the input type controls on the form and then matches them to those in the file.

The program will automatically cope with adding new controls to the form or removing controls, it does this on start up.


Using the DataBase file produced by FDES
Using the resulting MS Access file

When you have finished FDES, you will have an Access format database file ( yourname.mdb and yourname.ldb) This contains tables which have names corresponding to the names of your forms (i.e. the form name property, not the name you save it as).

It also contains a ProjectStrings table. If you have used this to store strings for say message box error messages, you will need to access it as appropriate in your application.

The database files are used when you run your application. Copy them to your application's directory or set the path to them in an .ini file.

LOOK AT THE SAMPLE APPLICATION

The following  shows the things you should do:

1) Add the supplied sample code module to your project (FDESCOM.bas)

This contains routines which are called to access the database file as well as routines used by the help form and others.

2) Add a label or panel to your form to hold the prompt text, generally along the very bottom of the form. In the following, a control called LABEL1 has been used where the text is held as a caption property. You could also use a control with a text property by changing the flag, cap% to false.

Notes on the code to copy:

2) Use the Generate code option on the File menu to generate code into an ASCII file. Load the formname.cod file into e.g. NotePad and then selectively cut and paste it into your events code on the form. You can of course selectively paste it into the correct sub routines within the VB design environment if you wish but yoy may find it easier to open another copy of notepad, write, or word etc and load your VB form code into this. (This only works of course if you have saved it as text).

Note: If you do this before you have added any other code in the events, you can do a block copy in notepad, placing the new code after any menu descriptions. When the form is re-loaded, it will sort the new event code

A) 'General - declarations for Form level

rem Note that Form1 is the name of the form.

Dim Form1ResetFocusFlag%

rem The above is to avoid a cascade call to the events if an error is flagged in the keypress/lost focus checks below.

B) For forms with list/combo boxes, where you have pre-set items

Sub Form_Load ()

numberoflistcombos% = 2

   ReDim temptagstore$(1)

   ReDim nameofthislistcombo$(1)

   nameofthislistcombo$(0) = "Combo1"

   nameofthislistcombo$(1) = "List1"

   'cannot do this in a loop since we cannot read/write/store control name properties.

     temptagstore$(0) = Combo1.Tag

     'give it a unique assigned tag to identify it

     Combo1.Tag = "loaduplistcontrol0"

     temptagstore$(1) = List1.Tag

     'give it a unique assigned tag to identify it

     List1.Tag = "loaduplistcontrol1"

   formname$ = "Form1"

   Call loadtogglesfromdbase(Form1, formname$, nameofthislistcombo$(), thismask)

   'restore the user assigned tagnames

     Combo1.Tag = temptagstore$(0)

     List1.Tag = temptagstore$(1)

   'finally erase the temp arrays

   Erase temptagstore$

   Erase nameofthislistcombo$

NB Note the parameter SimpleTest is the name of the form and is not a string

End Sub

C) For controls which can have an input:

i) 'Sub Text2_GotFocus ()

Call readtablefromdbase("Form1", thismask, "Text2")

rem this call reads the mask details from the FDES produced database file and stores them in a thismask structure.

rem note Form1 here is a string corresponding to the form name.

    cap% = True

    Call showpromptandhelp(label1, cap%)

rem these last two display the prompt text in label1.caption on the form.

'End Sub

Note that you need to change Form1 to whatever your form is called and Text2 to whatever the control is called (e.g. Command1, text1(index) etc.). If you have used the generate code option, this has all been done for you in the file *.cod

ii) 'Sub Text2_KeyPress (KeyAscii As Integer)

Form1ResetFocusFlag% = False

rem checks each keypress as you make it

    Call filterinput(KeyAscii%, thismask)

'End Sub

iii) 'Sub Text2_LostFocus ()

Call textlostfocuscheck(Form1ResetFocusFlag%, Text2)

rem does a min/max check, date format check etc as necessary.

'End Sub

Note that you need to change Form1 to whatever your form is called and Text2 to whatever the control is called (e.g. Command1, text1(index) etc.). If you have used the generate code option, this has all been done for you in the file *.cod

D) For controls without an input

i)'Sub Command1_GotFocus ()

Call readtablefromdbase("Form1", thismask, Command1)

    cap% = True

    Call showpromptandhelp(label1, cap%)

'End Sub

ii)'Sub Command1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)

   If Button = 2 Then

      Command1.setfocus

   End If

'End Sub

Note this last MouseDown code -used if you want your user to be able to click the right hand mouse button to move focus to a command button without actually generating a click event.

This sets focus to the button, thus triggering the GotFocus event which of course reads and displays the prompt and help text.


Things still to do yourself

Do something about mandatory inputs. This is best left to a specific check of all inputs on a command click event, e.g. a calculate button. This is because the user can use a mouse to move to any input box on a form in a random order. Specific checks of cross validation must also therefore be done at this time.

Add code for user defined flags, if you want. You can use up to 10 characters in each of the 5 boxes. When you read the mask, they are returned as mask.udf1$ to mask.udf5$.

Add specific event handling, e.g. validation other than the auto provided

 via the DB file and Sub filterinput in FDESCOM.BAS.

You will also need to make changes here if you have added any other flags to the list box in FDES via FDES.INI.


See a graph

Click on any column to see hotspots in action!

Using VB only

Using VB + Tools

Using BMC's FDES


Using VB only, graph
Using VB only


Using VB with tools, graph
Using VB + Tools


Using VB with FDES, graph
Using BMC's FDES


Installing and customising FDES

FDES comes without a windows installation program in order to keep down the size.

You will need to copy the files ending .vbx, .dll and .lic to your windows/system directory.

The other files can be left in a directory of your choice BUT you need to alter the text file FDES.INI to reflect the new path.

Altering the FDES.INI file

The following files are required by this program:

In the chosen directory

1) 	FDES.EXE	Main .exe file

2) 	FDES.INI	Standard Windows format .INI file

3) 	FDESdes.MDB	Database file holding input masks and help text

4) 	FDESdes.LDB	Control file for above

5)	FDES.HLP	This help file

In the Windows/System directory

1)	VBRUN300.DLL	Main VB3 run time file

2) 	VBDB300.DLL	Needed for data access

3)	MSAES110.DLL	Needed for data access

4)	MSAJT110.DLL	Needed for data access

5)	CMDIALOG.VBX	For common dialog control

6)	COMMDLG.DLL	For common dialog control

7)	THREED.VBX	Gives 3D command buttons with icons

8)	GRID.VBX	Standard VB GRID control

9)	SPIN.VBX	Standard VB SPIN control

10)	CBK.VBX	Various behind the scenes tasks!

11)	SBCKBD.VBX 	Various behind the scenes tasks!

12)	SPYPVBX.VBX	Various behind the scenes tasks!

13)	VSVBX.VBX	Gives various facilities inc. 3D and re-size

14)	VSVBX.LIC	License file for the above

15)	DWSPYDLL.DLL	Various behind the scenes tasks!

Since you must have the pro edition of VB3 to make use of this program, the files 1 to 4 above are not included since they are part of VB3 professional.

Files 5 to 9 are also included in the VB3 pro package but are included here in case you do not have the latest versions.


Altering the FDES.INI file

Alter the path below!

[General]

detailsdbname=d:\fdes\sample\sharever\FDESDES.mdb

'------------------ACCESS2 compatability layer users

'By default, the CreateDatabase function and CompactDatabase

'statement now create databases in Jet database engine 2.0 format.

'You can override this default behavior by using the DB_VERSION10

'constant (in the file DATACONS.TXT).

'Using this constant creates a version 1.1 database, not a version

'1.0 database.  You can't create version 1.0 databases.

'The following table shows which type of database is created

'when you use CreateDatabase and CompactDatabase with

'and without DB_VERSION10.

'-----------------------------------------------------------------

'Jet database engine   Creates by default      With DB_VERSION10

'-----------------------------------------------------------------

'Version 1.1           Version 1.1 database    Version 1.0 database

'Version 2.0           Version 2.0 database    Version 1.1 database

'so for FDES

'if you use v2 AND want a v1.1 database then set to true

'if you use V1.1 AND want a v1.0 then set to true(-1)

'i.e. for most users, leave alone!, ie=0

UseDBV10=0

'******************

[List of Input types]

'note that you can add your own

'just make sure the numbering is sequential and that

'there is no space between the equals and the number

'you will also have to amend the code in fdescom.bas, sub filterinput

'in your application to use the new flag values

'DO NOT REMOVE OR CHANGE NUMBERS 1 to 8

itype=1- Any printable character, automatic conversion to upper case

itype=2- As above, but no automatic conversion to upper case

itype=3- Name with auto convert 1st letters to ucase

'NB Change this to say, J,N and you need to change the code in

'fdescom.bas, proc filterinput to pick up the allowed ascii chars.

itype=4- Y Or N only

itype=5- Numeric, including decimals

'note that these date formats are only flags of length, at this stage

'the international separator or order does not matter

'code in fdescom.bas,sub basicdatecheck in your application will handle the difference

itype=6- Date as ddmmyy, mmddyy, etc.                     (length  6)

itype=7- Date as e.g. dd/mm/yy, mm/dd/yy,dd.mm.yy etc.    (length  8)

itype=8- Date e.g. dd/mm/ccyy,mm/dd/ccyy,mm.dd.ccyy etc.  (length 10)


The sample program

This shows you how to use the results of FDES

Both an .exe and source code is included in the files

1) sample.exe

2) sample.mak

3) sample.frm

4) sample.ini  --- NB! Be sure to alter the path

5) Sample.mdb

6) sample.ldb

7) helpdis1.frm

8) helpdis1.frx

9) fdescom.bas - this is the code module to include in all your projects which use FDES

REGISTER

10) fdesreg.txt - gives details on how to register etc.


Mike Richardson, BMC Programs Ltd, Shrewsbury

Tel 0743-248515

BMC Programs also have an excellent screen designer for Quick Basic or PDS 7.1.